home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / UTIL / Cron 1.0a7.sit / Cron Distribution / Documentation / READ ME < prev    next >
Text File  |  1996-05-27  |  18KB  |  296 lines

  1.  
  2. cron
  3. ゥ1991-96 Chris W. Johnson, All Rights Reserved.
  4. This program is $10 shareware.
  5.  
  6.  
  7. Author Email:     chrisj@kagi.com
  8. Author Page:   http://gargravarr.cc.utexas.edu/
  9. Product Page:  http://gargravarr.cc.utexas.edu/cron/cron.html
  10.  
  11.  
  12. Cron is a program that launches other programs (including AppleScript applets) at preset times. This scheduling of program launches can be as simple as メrun this program every hourモ or メrun this program at noon every day,モ or as sophisticated as メrun this program every third minute during the four oユclock hour on the first Monday of every month.モ It is based directly on the cron dセmon in the BSD Unix operating system (there is no common code at any level, however), and has been in widespread use on the Macintosh since shortly after System 7.0 was released in 1991.
  13.  
  14. Cron is a conventional Macintosh application that runs in the background of your Mac. Since it is neither a system extension nor a control panel, it does not expose your Mac to the wide range of compatibility problems commonly associated with extensions and their trap patches.
  15.  
  16.  
  17. Contents
  18. __________________
  19.  
  20. ・ System Requirements
  21. ・ Installation
  22. ・ Removal
  23. ・ Crontab Format
  24.       ・ Crontab Examples
  25.       ・ Obscure Parsing Notes
  26. ・ Extensions to the Crontab Format
  27.       ・ startup
  28.       ・ shutdown
  29.       ・ idle
  30.       ・ idlescreen
  31.       ・ busy
  32. ・ Items Cron Can Launch
  33.       ・ Applications
  34.       ・ Applications by Creator Code
  35.       ・ AppleScript Applets
  36.       ・ Cron Commands
  37.       ・ Desk Accessories
  38.       ・ Documents
  39.  
  40.  
  41.  
  42.  
  43. SYSTEM REQUIREMENTS
  44. ______________________________________
  45.  
  46. ・ System >= 7.0
  47. ・ Appleユs Thread Manager extension (built into Systems >= 7.5)
  48.  
  49. Strictly speaking, Cron only requires System 7, but the Cron Setup application requires both System 7 and the Thread Manager. In order for the SIVC features to operate (SIVC allows Cron to automatically tell you when new versions of itself are available, and then optionally assists you in downloading them), you must also have MacTCP or OpenTransport installed, as well as Internet Config version 1.1 or better.
  50.  
  51. Need Appleユs Thread Manager? It can currently be found in the following location:
  52. ftp://ftp.austin.apple.com/Apple.Support.Area/Apple.Software.Updates/US/Macintosh/System/Other_System/
  53.  
  54. Need Internet Config? Check your favorite Macintosh archive site, or look here for info:
  55. http://www.share.com/peterlewis/programs.html#InternetConfig
  56.  
  57.  
  58. INSTALLATION
  59. ______________________________________
  60.  
  61. Run the Cron Setup application and it will install Cron for you. Note that Cron Setup should remain in the same folder as Cron, メSIVC Query Engine,モ メRegister,モ and all the Cron commands. For your convenience, you may want to create an alias to Cron Setup and place that alias in your Control Panels folder, although thereユs no requirement to do so.
  62.  
  63. Because Cron is a conventional application (albeit a background-only application), rather than an extension, there is no need to restart your Macintosh after installation; Cron is active immediately.
  64.  
  65.  
  66. REMOVAL
  67. ______________________________________
  68.  
  69. If you want to remove Cron, run Cron Setup and pick the メCron Manual Launch Onlyモ item from the メSpecialモ menu. Cron will be off after you restart your Mac. If you want to turn off Cron immediately, just pick the メCron Offモ item from the メSpecialモ menu.
  70.  
  71.  
  72. CRONTAB FORMAT
  73. ______________________________________
  74.  
  75. The メcrontabモ file is the text file in which all of Cronユs scheduling information is stored. By メscheduling informationモ we mean the information that tells Cron when something should happen, and exactly what Cron shoud do at that time. In order to edit the crontab file, just run the メCron Setupモ application and click the メEdit Scheduleモハbutton in the メCron Setupモ window. The format of the crontab file will be familiar to anyone who has used Cron on a UNIX-based computer. For the rest of us, however, it requires some explaining (and ultimately a graphical user interface, if thereユs really a market for this product)....
  76.  
  77. The crontab file consists of lines of seven fields each. The fields are separated by spaces or tabs (which means that the fields cannot containspaces or tabs). The first five fields are integer patterns that specify:
  78.  
  79.         Field 1 ミ Minute (range: 0-59)
  80.         Field 2 ミ Hour (range: 0-23)
  81.         Field 3 ミ Day of the month (range: 1-31)
  82.         Field 4 ミ Month of the year (range: 1-12)
  83.         Field 5 ミ Day of the week (range: 1-7, where 1=Monday)
  84.  
  85. Each pattern can contain:
  86.  
  87. ・ A number in the range above.
  88. ・ Two numbers separated by a minus (-) sign means an inclusive range. The final element of the range can now be an asterisk (*), which will represent the largest permissible value in any given field. Support for an asterisk here is non-standard, and not part of the UNIX Cron specification.
  89. ・ A list of numbers separated by commas means any of the numbers.
  90. ・ An asterisk (*) means all legal values.
  91.  
  92. (If you havenユt dealt with Cron before, this may make no sense at all to you. See the メCrontab Examplesモ subsection below for some examples.)
  93.  
  94. The sixth field is a user name. This is required for compatibility, but is not currently used. Just supply a dummy value in this field. (In the examples, the dummy string メnobodyモ is used.)
  95.  
  96. The seventh field consists of all the text on the line after the sixth field, including tabs and spaces. This field is the command that is to be executed when all of the conditions described by fields 1-5 are met. 
  97.  
  98. The seventh field may begin with an optional argument containing switches which control cronユs handling of the program to be launched. The switch characters should be immediately preceded by a dash (-) character. Those switches are as follows:
  99.  
  100. ヤbユ  ム  Launch program in background. Otherwise, program is launched into the foreground.
  101.  
  102. ヤlユ  ム  Log the launch and exit of this program. This option overrides the メLog Successesful Actionsモ and メLog Errorsモ options in the Cron Log Preferences dialog, but only if Cron is currently maintaining a log file, i.e. if the メMaintain a Log Fileモ option is disabled, nothing will be logged under any circumstances.
  103.  
  104. Thus, if the seventh field looked like this:
  105.  
  106.         -lb wombat
  107.  
  108. The メwombatモ program would be launched into the background, and its launch and exit would be logged (assuming the log is turned on, of course). If the seventh field merely looked like this:
  109.  
  110.         wombat
  111.  
  112. The メwombatモ program would be launched into the foreground, and it might, or might not, be logged depending on the settings in the cron preferences file.
  113.  
  114. Incorrectly constructed lines are ignored. No errors are reported to the user.
  115.  
  116. Cron automatically examines the crontab file for changes every minute, on the minute.
  117.  
  118. Crontab Examples
  119. __________________
  120.  
  121. Below are some simple examples of crontab entries which should help you understand the format and meaning of crontab lines. Since this isnユt meant to provide a demonstration of the various cron commands, weユre only using the メechoモ command in these examples. Echo merely displays a message on your screen for a short period of time. (Note that the example crontab lines below are indented for clarity; they should not be indented in the actual crontab file.)
  122.  
  123. Run the メechoモ command to display an alert telling you to leave the office every weekday at 5:00 PM:
  124.  
  125.         0 17 * * 1-5 nobody echo "It's 5:00 and time to go home now."
  126.  
  127. Remind yourself of your dogユs birthday (October 27th) just before the end of the workday (4:45 PM) , so you wonユt forget to buy him a present on the way home from work:
  128.  
  129.         45 16 27 10 1-5 nobody echo "It's the dog's birthday today!"
  130.  
  131. Of course, the dogユs birthday will fall on a weekend two out of every seven years, so youユll want a different reminder on those occasions. Probably the best way to handle this from the Mac in your office is to have it remind you before you leave the office on any Friday afternoon (weユll use 4:45 PM again) which happens to be the 25th or 26th of October (remember that the dogユs birthday is October 27th):
  132.  
  133.         45 16 25,26 10 5 nobody echo "The dog's birthday is this weekend (the 27th)!"
  134.  
  135. Still, itユs easy to miss these messages if you arenユt around when they appear, so you may want to increase your chances of seeing them by having them appear several times during the day. For example, at 9:45 AM, 1:45 PM, and 4:45 PM. The change to the previous two example crontab lines is simple, and involves altering only the second field (the メhoursモ field) of those lines:
  136.  
  137.         45 9,13,16 27 10 1-5 nobody echo "It's the dog's birthday today!"
  138.         45 9,13,16 25,26 10 5 nobody echo "The dog's birthday is this weekend (the 27th)!"
  139.  
  140. Remember that hours are specified in the range 0-23, where 0 is midnight (12:00 AM) and 23 is 11:00 PM. So in the two example lines above, 9 specifies the 9 AM hour, 13 specifies the 1 PM hour, and 16 specifies the 4 PM hour.
  141.  
  142. Obscure Parsing Notes
  143. __________________
  144.  
  145. Unlike the UNIX Cron, a % character in the seventh and following fields is not translated to a newline character.  
  146.         
  147. Escape sequences are supported in all fields, so preceding a character by a backslash (¥) will cause the character to be ignored for parsing purposes. In addition, the standard set of escape sequences are supported:
  148.  
  149.         ¥a      alert (bell) character
  150.         ¥b      backspace
  151.         ¥f      formfeed
  152.         ¥n      newline
  153.         ¥r      carriage return
  154.         ¥t      horizontal tab
  155.         ¥v      vertical tab
  156.         ¥¥      backslash
  157.         ¥?      question mark
  158.         ¥'      single quote
  159.         ¥"      double quote
  160.             
  161. Hexadecimal (¥xhh) and Octal (¥ooo) sequences are not currently supported, however.
  162.         
  163. Double quotes can be used to delimit fields. For example, the file name "READ ME" is interpreted as a single field if it is surrounded by double quotes, but as two fields ("READ" and "ME") if the quotes are omitted. The parsing code is not currently sensitive to single quotes.
  164.  
  165.  
  166. EXTENSIONS TO THE CRONTAB FORMAT
  167. ______________________________________
  168.  
  169. This version of Cron for the Macintosh includes some unique extensions to the crontab format in order to allow scheduling on the basis of things other than just time and date.  (Obviously, these are non-standard, but they can be useful.)
  170.  
  171. These extensions are added to the beginning of valid lines in the crontab file.  They begin with a word specifying the type of case they represent, continue with a case-specific set of parameters, and conclude with a colon (:).  Following the colon should be a normal, 7 field crontab line as detailed in the preceding section of this document.
  172.  
  173. Example:  
  174.  
  175.         idle 4-* : * * * * * nobody -b beep
  176.  
  177. The example above begins with the word specifying the case (メidleモ), includes a parameter (メ4-*モ) which is specific to the メidleモ case, terminates the special case portion of the line with a colon (:), and then goes on with a perfectly normal crontab line which happens to invoke the メbeepモ command in the background.
  178.  
  179. Note that all the numeric values discussed below can be a single value, a range of values, a list of values, or an asterisk (*) representing all values. Also, remember that Cron still executes commands only once a minute, on the minute.
  180.  
  181. startup
  182. __________________
  183.  
  184. Schedules execution of a command relative to the time at which the cron application is launched.
  185.  
  186.         Format:  startup N : (normal crontab line)
  187.  
  188. N is the number of minutes after startup at which the command should be executed.
  189.  
  190. shutdown
  191. __________________
  192.  
  193. Schedules execution of a command for the moment when the cron application exits.
  194.  
  195.         Format:  shutdown : (normal crontab line)
  196.  
  197. idle
  198. __________________
  199.  
  200. Schedules execution of a command relative to the length of time the Mac has been idle, where メidleモ means that the mouse has not moved and the keyboard has not been used. Perfect detection of keyboard use is not possible from an application, so don't be surprised if this case isn't always handled perfectly, particularly with small delay values. 
  201.  
  202.         Format:  idle N : (normal crontab line)
  203.  
  204. N is the number of minutes after the Mac goes idle at which the command should be executed.
  205.  
  206. idlescreen
  207. __________________
  208.  
  209. Works just like the メidleモ case, but is also sensitive to the corner (if any) of the main screen in which the mouse is located.  This is perfect for writing your own screen savers.
  210.  
  211.         Format:  idlescreen N A D : (normal crontab line)
  212.  
  213. N is the number of minutes after the Mac goes idle at which the command should be executed.
  214.  
  215. A is the number of the main screen corner which should cause the command to be executed.  (See diagram below.)
  216.  
  217. D is the number of the main screen corner which should prevent the command from being executed.  (See diagram below.)
  218.  
  219. Screen Corner Numbers:
  220.  
  221.          1---------2     0 -- No corner.
  222.          |         |     1 -- Upper-left corner.
  223.          |    0    |     2 -- Upper-right corner.
  224.          |         |     3 -- Lower-left corner.
  225.          3---------4     4 -- Lower-right corner.
  226.  
  227. Screen corners are 32x32 pixel squares, so positioning the mouse in them is no challenge.
  228.  
  229. busy
  230. __________________
  231.  
  232. Schedules execution of a command relative to the length of time the Mac has been busy, where メbusyモ means that the mouse has been moved and/or the keyboard is in use.  (The same caveats that apply to the idle command also apply here.)
  233.  
  234.         Format:  busy N : (normal crontab line)
  235.  
  236. N is the number of minutes after the Mac becomes busy at which the command should be executed.
  237.  
  238.  
  239. ITEMS CRON CAN LAUNCH
  240. ______________________________________
  241.  
  242. Field 7 of every crontab entry specifies the name of an item to be launched or opened, and some optional arguments. Since there has been some confusion as to what sort of items Cron can launch/open (and these capabilities were extended in Cron 1.0a7) weユll go into detail about them here. Note that in all the examples that follow, weユll use dummy values for the first six fields of the crontab entries (メ* * * * * nobodyモ), since theyユre not relevant to what weユre trying to illustrate here.
  243.  
  244. Applications by Name
  245. __________________
  246.  
  247. Cron can launch applications. Place the application, or an alias to it, in the same folder as Cron and use the itemユs name as the command name. If we want Cron to launch the メSimple Textモ application, or an alias to it:
  248.  
  249.         * * * * * nobody "Simple Text"
  250.         * * * * * nobody "Simple Text alias"
  251.  
  252. Note that Cronユs so-called メcommandsモ are themselves merely applications, but they accept additional arguments to control their behavior (such as the message strings supplied to the メechoモ command in the examples earlier in this document). See the document メCron Commandsモ for information on each of the commands and the arguments they expect.
  253.  
  254. Applications by Creator Code
  255. __________________
  256.  
  257. In addition to launching applications by their names as illustrated in the examples above, Cron can launch applications using their unique four letter creator codes (also know as メapplication signaturesモ or autographs). The advantage of this approach is that you donユt have to place the application (or an alias to it) in Cronユs folder. Cron locates the application for you by searching the Desktop Database. The disadvantages of this approach are: (1) you have to know what a creator code is, (2) you have to know how to determine what it is for any given application, and (3) using creator codes may make it harder for you to read your own crontab entries at a later date. Nonetheless, if you wanted to launch Eudora, whose creator code happens to be "CSOm", youユd setup the crontab entry like this:
  258.  
  259.         * * * * * nobody "CSOm"
  260.  
  261. AppleScript applets
  262. __________________
  263.  
  264. AppleScripts must be saved as applets in order for Cron to launch them. Place the applet, or an alias to it, in the same folder as Cron and use the itemユs name as the command name. If we want Cron to launch the AppleScript applet メBobユs Backup Scriptモ, or an alias to it:
  265.  
  266.         * * * * * nobody "Bobユs Backup Script"
  267.         * * * * * nobody "Bobユs Backup Script alias"
  268.  
  269. Note that because Cron passes arguments to its commands using AppleEvents, it is possible to write you AppleScripts such that they can accept arguments supplied in the crontab file just like conventional cron commands. Jerry Straton has prepared a good page describing how to do this. The URL is:
  270.  
  271.         http://nspace.cts.com/html/NetLife/NSpace/NSC/Cron.html
  272.  
  273. Another pleasant effect of cron commands receiving their arguments via AppleEvents is that AppleScripts can invoke cron commands and pass arguments to them just as Cron itself can. Jerryユs page also describes how to do that.
  274.  
  275. Cron Commands
  276. __________________
  277.  
  278. See the document メCron Commandsモ for information on how to use the various cron commands supplied in this release.
  279.  
  280. Desk Accessories
  281. __________________
  282.  
  283. Place the DA, or an alias to it, in the same folder as Cron and use the itemユs name as the command name. If we want Cron to launch the DA メAlarm Clockモ, or an alias to it:
  284.  
  285.         * * * * * nobody "Alarm Clock"
  286.         * * * * * nobody "Alarm Clock alias"
  287.  
  288. Documents
  289. __________________
  290.  
  291. Place the document, or an alias to it, in the same folder as Cron and use the itemユs name as the command name. The application that created the document will be found (via a search of the Desktop Database), launched, and instructed to open the document. So, if we want Cron to open a Simple Text document named メREAD MEモ, weユd place the document, or an alias to it, in the same folder as Cron and weユd construct a crontab entry like the following:
  292.  
  293.         * * * * * nobody "READ ME"
  294.         * * * * * nobody "READ ME alias
  295.  
  296.